<?php
class DashboardController extends AppController {
    
    public $uses = array('Video');
    
    public function index() {
        
        $data = array();
        $query = sprintf('select count(*) as total_video from contents where type="video" ');
        $tmp = $this->Video->query($query);
        $data['total_video'] = $tmp[0][0]['total_video'];
        
        $query = sprintf('select
                          SUM(1) as total_jobs,
                          SUM(if(video_flavors.status = "completed",1,0)) as complete,
                          SUM(if(video_flavors.status = "inprocess",1,0)) as inprocess
                          from video_flavors group by video_flavors.status');
        
        $tmp = $this->Video->query($query);
        $data = array_merge_recursive($data,$tmp[0][0]);
        $this->set('title','Dashboard');
        $this->set('subtitle','Control panel');
        $this->set('data',$data);
    }
}